// 包含多个基于state的getter计算属性的对象

export default{
    totalCount(state){
        return state.cartFoods.reduce((proTotal, food) => proTotal + food.count, 0)  
        //数组累加：reduce((初始值,处理数组的当前元素)=>，初始值)，
    },
    totalPrice(state){
        return state.cartFoods.reduce((proTotal, food) => proTotal + food.count*food.price, 0)
    },

    positiveSize(state){
        return state.ratings.reduce((proTotal, rating) => proTotal + (rating.rateType === 0 ? 1 : 0), 0)
    }
}